#ifndef BMA180_h
#define BMA180_h

#include "Arduino.h"
#include "ACCEL_v1.h"

/*
BMA180 implements a simple interface to the BOSCH BMA180 3-axis accelerometer

This class reads the acceleration values and allows the setting of gain and bandwidth

Gain and bandwidth settings can be stored in the BMA180 eePROM
*/

class BMA180 : public ACCEL
{
   public:
      BMA180(void);
      void get_accel(void);        // Reads acceleration values from BMA180
      void set_gain(byte gain);    // Sets the gain value
                                   // { 0:1g, 1:1.5g, 2:2g, 3:3g, 4:4g, 5:8g, 6:16g}
      int get_gain(void);          // Returns the current gain setting (see above)
      void set_bw(byte bw);        // sets the bandwidth value
                                   // {0:10Hz, 1:20Hz, 2:40Hz, 3:75Hz, 4:150Hz, 5:300Hz,
                                   //  6:600Hz, 7:1200Hz, 8:hi-pass,1Hz, 9:band-pass,0.2-300Hz}
      byte get_bw(void);           // Returns the current BW setting (see above)
      void ee_write_gain(void);    // Writes the current gain setting to eePROM
      void ee_write_bw(void);      // Writes the current bw setting to eePROM
      //int x_accel;                 // The x- (y-, z-) Acceleration values from last get_accel()
      //int y_accel;                 // Scale factor = 1.95 (+/- 0.06) mg/LSB 
      //int z_accel;                 //              = 0.01911 m/s2/LSB

      
   private:
      int _accADDR;    // I2C Bus Address of BMA180 Accelerometer
      byte _aRANG;    // BMA180 Range Register Word Address
      byte _aACCL;    // BMA180 Acceleration Register Base
      byte _aBAND;    // BMA180 BW Register Address
      byte _aEEWR;    // BMA180 EEPROM Write register offset
      byte _aRMSK;    // Range bit mask
      byte _aBMSK;    // BW bit mask
      byte _aECTL;    // ee_w control register
      byte _aEE_W;    // ee_w bit
      void _write_lock(boolean lock);  // Lock/Unlock Image/EEPROM writing
};

#endif
